package common

import (
	"log"
	"os"
	"runtime/pprof"
)

func StartProfile(profile string) {
	if profile == "cpu" {
		f, err := os.Create("cpu.prof")
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
	}
}

func EndProfile(profile string) {
	if profile == "cpu" {
		pprof.StopCPUProfile()
	}
	if profile == "mem" {
		f, err := os.Create("mem.prof")
		if err != nil {
			log.Fatal(err)
		}
		pprof.WriteHeapProfile(f)
	}
}
